<!doctype html>
<html>
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no">

    <title>reveal.js</title>

    <link rel="stylesheet" href="css/reveal.css">
    <link rel="stylesheet" href="css/theme/mystyle.css">

    <!-- Theme used for syntax highlighting of code -->
    <link rel="stylesheet" href="lib/css/zenburn.css">

    <!-- Printing and PDF exports -->
    <script>
        var link = document.createElement('link');
        link.rel = 'stylesheet';
        link.type = 'text/css';
        link.href = window.location.search.match(/print-pdf/gi) ? 'css/print/pdf.css' : 'css/print/paper.css';
        document.getElementsByTagName('head')[0].appendChild(link);
    </script>
</head>
<body>
<div class="reveal">
    <div class="slides">
        <!-- 封面 -->
        <section data-background-color="#000">
            <h2>分布式数据库</h2>
            <small class="author-name">何骞</small>
            <p>2018-4-12</p>
        </section>
        <!-- DB 演变 -->
        <section>
            <h1>DB</h1>
            <img class="fragment" src="images/db_evolution.jpg">
        </section>

        <section data-transition-speed="slow">
            <h2>单机数据库</h2>
            <p class="fragment">把数据存下来</p>
            <p class="fragment">满足数据的计算需求</p>
        </section>
        <section data-transition="zoom">
            <section data-transition-speed="slow">
                <img src="images/sea.jpg">
                <h2>随着数据规模爆炸式增长</h2>
            </section>
            <section data-transition-speed="fast">
                <h2><span class="fragment highlight-blue">分布式数据库</span>走上神坛</h2>
                <p class="fragment">Nosql （MongoDB 分片，redis）</p>
                <p class="fragment">RDBMS + 中间件（Mycat，Cobar，TDDL ），实现读写分离、垂直拆库、水平分表</p>
            </section>
            <section data-transition-speed="slow">
                <h2>痛点</h2>
                <p class="fragment">实现容量的<span class="fragment highlight-green">水平扩展</span></p>
                <p class="fragment"> 但代价是<span class="fragment highlight-red">牺牲事务</span>
                    或是<span class="fragment highlight-red">简化数据模型</span>，只提供简单的KV模型，降低对业务的支撑</p>
            </section>
            <section>
                <p class="fragment">分库导致增加业务复杂度（例如查询后需要数据合并）</p>
                <p class="fragment">对sql进行阉割，不支持一些复杂sql（例如复杂的join操作）</p>
                <p class="fragment">无法支持在线扩容，有的需要人工参与，甚至停服，成本巨大</p>
            </section>
        </section>
        <section data-transition="zoom">
            <h1>NewSql</h1>
            <p class="fragment">随着Google的Spanner和F1论文发布，
                让业界第一次看到了关系模型和 NoSQL 的扩展性在一个大规模生产系统上融合的可能性。</p>
        </section>

        <!-- Tidb -->
        <section data-transition="zoom">
            <section data-transition-speed="fast" data-background-color="#fff">
                <img src="images/logo_tidb.png">
                <p class="fragment">高可用</p>
                <p class="fragment">支持<span class="fragment highlight-red">在线自动</span>扩容缩容</p>
                <p class="fragment">支持OLAP + OLTP</p>
                <p class="fragment">全面兼容mysql协议</p>
            </section>
            <!-- Tidb 架构图-->
            <section data-transition-speed="fast">
                <h2>架构剖析</h2>
                <img src="images/tidb.png">
            </section>
            <!-- select 流程-->
            <section data-transition-speed="fast">
                <img src="images/tidb_select.jpg">
            </section>
            <!-- 容灾 -->
            <section data-transition-speed="fast">
                <h2>容灾</h2>
                <img src="images/raft.png">
            </section>
            <!-- 性能监控-->
            <section data-transition-speed="fast">
                <h3>性能监控</h3>
                <img src="images/storage.png">
            </section>
            <section data-transition-speed="fast">
                <img src="images/grafana-screenshot.png">
            </section>
        </section>

        <!-- 踩坑日常 -->
        <section data-transition="zoom">
            <section data-transition-speed="fast">
                <h2>干货：踩坑日常</h2>
                <img src="images/pit.jpg">
            </section>
            <section data-transition-speed="fast">
                <h2>节点大量挂掉</h2>
                <img class="fragment" src="images/tidb-daily-1-4.png">
            </section>
            <section data-transition-speed="fast">
                <h2>热点问题</h2>
                <p class="fragment">自增id</p>
                <p class="fragment">单调递增索引（例如时间戳）</p>
            </section>
        </section>

        <section data-transition="zoom">
            <h2>分布式数据库性能一定 > 单机？</h2>
            <p class="fragment">数据量低于5000W的场景用不到</p>
            <p class="fragment">单机数据库能满足的场景也用不到</p>
        </section>
        <!-- 个人观点 -->
        <section data-transition="zoom">
            <h2>未来的数据库</h2>
            <p class="fragment fade-up current-visible">势必会是OLAP和OLTP的融合</p>
            <p class="fragment fade-up current-visible">高可用和自动化运维会成为标配</p>
            <p class="fragment fade-up current-visible">Raft等一致性算法取代主从日志同步</p>
            <p class="fragment fade-up current-visible">云化</p>
        </section>
        <!-- end -->
        <section data-transition="convex">
            <p class="fragment fade-up current-visible">博客:7le.top 里有选型Tidb时的测评和完整踩坑日常</p>
            <p class="fragment fade-up current-visible">Thanks！</p>
        </section>
    </div>
</div>

<script src="lib/js/head.min.js"></script>
<script src="js/reveal.js"></script>

<script>
    Reveal.initialize({
        history: true,
        // 是否显示当前幻灯片的页数
        slideNumber: 'c/t',
        dependencies: [
            {src: 'plugin/markdown/marked.js'},
            {src: 'plugin/markdown/markdown.js'},
            {src: 'plugin/notes/notes.js', async: true},
            {
                src: 'plugin/highlight/highlight.js', async: true, callback: function () {
                    hljs.initHighlightingOnLoad();
                }
            }
        ]
    });
</script>
</body>
</html>
